<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
function test() {
    jsTestAsync = true;
    if (window.testRunner)
        testRunner.dumpAsText();

    if (!window.eventSender)
        return;

    if (!eventSender.gestureLongPress) {
        debug("gestureLongPress not implemented by this platform.");
        debug("Manullay long press on every element in the page and check whether Paste Popup is appearing or not");
        debug("If Paste popup is appearing for readonly or disabled input/textarea, then it's a failure.");
        return;
    }

    // Normal Text
    doLongPressOnElement("normalText");

    // ReadOnly Text
    doLongPressOnElement("readOnlyText");

    // Disabled Text
    doLongPressOnElement("disabledText");

    // ReadOnly and Disabled Text
    doLongPressOnElement("readOnlyDisabledText");

    // Normal TextArea
    doLongPressOnElement("normalTextArea");

    // ReadOnly TextArea
    doLongPressOnElement("readOnlyTextArea");
					
    // Disabled TextArea
    doLongPressOnElement("disabledTextArea");

    // ReadOnly and Disabled TextArea
    doLongPressOnElement("readOnlyDisabledTextArea");

    finishJSTest();
}

function doLongPressOnElement(elementId) {
    var element = document.getElementById(elementId);
    var bounds = element.getBoundingClientRect();
    var middleX = (bounds.left + bounds.right) / 2;
    var middleY = (bounds.top + bounds.bottom) / 2;
    // Touch directly in the center of the element.
    eventSender.gestureLongPress(middleX, middleY);
    var touchNode = document.elementFromPoint(middleX, middleY);
    shouldBe(touchNode.id, elementId);
}
</script>
</head>
<body onload="test();">
<input id="normalText" type="text" value="Normal input">
<input id="readOnlyText" type="text" value="Readonly input" readonly>
<input id="disabledText" type="text" value="Disabled input" disabled>
<input id="readOnlyDisabledText" size="20" type="text" value="Readonly Disabled input"readonly disabled>
<textarea id="normalTextArea" cols="31">Normal textarea</textarea>
<textarea id="readOnlyTextArea" cols="31" readonly>Readonly textarea</textarea>
<textarea id="disabledTextArea" cols="31" disabled>Disabled textarea</textarea>
<textarea id="readOnlyDisabledTextArea" cols="31" readonly disabled>Readonly Disabled textarea</textarea>
</body>
</html>

